//
//  CLConstant.h
//  CLApp
//
//  Created by chuck on 2018/10/5.
//  Copyright © 2018年 CCYQ. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "CLUserDefaults.h"
/// Block
///------ __nullable
typedef void (^VoidBlock)(void);
typedef BOOL (^BoolBlock)(void);
typedef int  (^IntBlock) (void);
typedef id   (^IDBlock)  (void);

typedef void (^VoidBlock_int)(int);
typedef BOOL (^BoolBlock_int)(int);
typedef int  (^IntBlock_int) (int);
typedef id   (^IDBlock_int)  (int);

typedef void (^VoidBlock_string)(NSString *);
typedef BOOL (^BoolBlock_string)(NSString *);
typedef int  (^IntBlock_string) (NSString *);
typedef id   (^IDBlock_string)  (NSString *);

typedef void (^VoidBlock_id)(id);
typedef BOOL (^BoolBlock_id)(id);
typedef int  (^IntBlock_id) (id);
typedef id   (^IDBlock_id)  (id);

typedef void (^ValueChangedBlock)(UISwitch *);
typedef void (^VoidBlock_callBack)(id,NSError *);
#pragma mark - 应用相关的
/// 切换根控制器的通知 新特性
FOUNDATION_EXTERN NSString * const CLSwitchRootViewControllerNotification;
/// 切换根控制器的通知 UserInfo key
FOUNDATION_EXTERN NSString * const CLSwitchRootViewControllerUserInfoKey;
/// 插件Switch按钮值改变
FOUNDATION_EXTERN NSString * const CLPlugSwitchValueDidChangedNotification;
/// 全局分割线高度 .5
FOUNDATION_EXTERN CGFloat const CLGlobalBottomLineHeight;
/// 个性签名的最大字数为30
FOUNDATION_EXTERN NSUInteger const CLFeatureSignatureMaxWords;
/// 用户昵称的最大字数为20
FOUNDATION_EXTERN NSUInteger const CLNicknameMaxWords;
/// 简书首页地址
FOUNDATION_EXTERN NSString * const CLMyBlogHomepageUrl ;
/// 国家区号
FOUNDATION_EXTERN NSString * const CLMobileLoginZoneCodeKey ;
/// 手机号码
FOUNDATION_EXTERN NSString * const CLMobileLoginPhoneKey ;
/// 验证码时间
FOUNDATION_EXTERN NSUInteger const CLCaptchaFetchMaxWords;
/// 全局分割线高度
FOUNDATION_EXTERN CGFloat const WXGlobalBottomLineHeight;
/// 微信朋友圈常量定义区
/// 头像宽高 15
FOUNDATION_EXTERN CGFloat const CLMomentProfileViewAvatarViewWH;
/// 消息tips宽高 40
FOUNDATION_EXTERN CGFloat const CLMomentProfileViewTipsViewHeight ;
/// 消息tips宽高 181
FOUNDATION_EXTERN CGFloat const CLMomentProfileViewTipsViewWidth ;
/// 消息tipsView内部的头像宽高 30
FOUNDATION_EXTERN CGFloat const CLMomentProfileViewTipsViewAvatarWH ;
/// 消息tipsView内部的头像距离tipsView边距 5
FOUNDATION_EXTERN CGFloat const CLMomentProfileViewTipsViewInnerInset ;
/// 消息tipsView内部的文字距离tipsView边距 18
FOUNDATION_EXTERN CGFloat const CLMomentProfileViewTipsViewMsgLeftInset;
/// 消息tipsView内部的文字距离tipsView边距 19
FOUNDATION_EXTERN CGFloat const CLMomentProfileViewTipsViewMsgRightInset;
/// 消息tipsView内部的右箭头距离tipsView边距 11
FOUNDATION_EXTERN CGFloat const CLMomentProfileViewTipsViewRightInset ;
/// 消息tipsView内部的右箭头宽高 15
FOUNDATION_EXTERN CGFloat const CLMomentProfileViewTipsViewRightArrowWH ;
//// 朋友圈新鲜
/// 新鲜内容距离顶部的间距 16
FOUNDATION_EXTERN CGFloat const CLMomentContentTopInset;
/// 新鲜内容距离左右屏幕的间距 20
FOUNDATION_EXTERN CGFloat const CLMomentContentLeftOrRightInset;
/// 内容（控件）之间的的间距 10
FOUNDATION_EXTERN CGFloat const CLMomentContentInnerMargin;
/// 用户头像的大小 44x44
FOUNDATION_EXTERN CGFloat const CLMomentAvatarWH;
/// 向上箭头W
FOUNDATION_EXTERN CGFloat const CLMomentUpArrowViewWidth ;
/// 向上箭头H
FOUNDATION_EXTERN CGFloat const CLMomentUpArrowViewHeight ;
/// 全文、收起W
FOUNDATION_EXTERN CGFloat const CLMomentExpandButtonWidth ;
/// 全文、收起H
FOUNDATION_EXTERN CGFloat const CLMomentExpandButtonHeight ;
/// pictureView中图片之间的的间距 6
FOUNDATION_EXTERN CGFloat const CLMomentPhotosViewItemInnerMargin;
/// pictureView中图片的大小 86x86 (屏幕尺寸>320)
FOUNDATION_EXTERN CGFloat const CLMomentPhotosViewItemWH1;
/// pictureView中图片的大小 70x70 (屏幕尺寸<=320)
FOUNDATION_EXTERN CGFloat const CLMomentPhotosViewItemWH2;
/// 分享内容高度
FOUNDATION_EXTERN CGFloat const CLMomentShareInfoViewHeight;
/// videoView高度
FOUNDATION_EXTERN CGFloat const CLMomentVideoViewHeight ;
/// videoView宽度
FOUNDATION_EXTERN CGFloat const CLMomentVideoViewWidth ;


/// 微信正文内容的显示最大行数（PS：如果超过最大值，那么正文内容就单行显示，可以点击正文内容查看全部内容）
FOUNDATION_EXTERN NSUInteger const CLMomentContentTextMaxCriticalRow ;
/// 微信正文内容显示（全文/收起）的临界行
FOUNDATION_EXTERN NSUInteger const CLMomentContentTextExpandCriticalRow ;
/// 单张图片的最大高度（等比例）180 (ps：别问我为什么，我量出来的)
FOUNDATION_EXTERN CGFloat const CLMomentPhotosViewSingleItemMaxHeight;
/// 更多按钮宽高 (实际：25x25)
FOUNDATION_EXTERN CGFloat const CLMomentOperationMoreBtnWH ;
/// footerViewHeight
FOUNDATION_EXTERN CGFloat const CLMomentFooterViewHeight ;


/**
 YYTextHighlight *highlight = [YYTextHighlight new];
 highlight.userInfo = @{kWBLinkHrefName : href};
 */
//// 这里是点击文本链接（or其他）跳转，通过该key从userInfo中取出对应的数据
/// 点击链接
FOUNDATION_EXTERN NSString * const CLMomentLinkUrlKey ;
/// 电话号码key
FOUNDATION_EXTERN NSString * const CLMomentPhoneNumberKey ;
/// 点击位置
FOUNDATION_EXTERN NSString * const CLMomentLocationNameKey;
/// 点击用户昵称
FOUNDATION_EXTERN NSString * const CLMomentUserInfoKey;
/// 信息
FOUNDATION_EXTERN NSString * const CLMomentKey;
/// 添加关注
FOUNDATION_EXTERN NSString * const CLMomentAttentItemViewModelKey;
/// 举报
FOUNDATION_EXTERN NSString * const CLMomentReportItemViewModelKey;
/// 评论View
/** 弹出评论框View最小高度 */
FOUNDATION_EXTERN CGFloat const CLMomentCommentToolViewMinHeight;
/** 弹出评论框View最大高度 */
FOUNDATION_EXTERN CGFloat const CLMomentCommentToolViewMaxHeight ;
/** 弹出评论框View的除了编辑框的高度 */
FOUNDATION_EXTERN CGFloat const CLMomentCommentToolViewWithNoTextViewHeight;

/// 更多操作View的Size 181x39
/// 更多操作View的Size 181x39
FOUNDATION_EXTERN CGFloat const CLMomentOperationMoreViewWidth ;
FOUNDATION_EXTERN CGFloat const CLMomentOperationMoreViewHeight ;

/// 微信动画时间 .25f
FOUNDATION_EXTERN NSTimeInterval const CLMommentAnimatedDuration;



//// 评论和点赞view 常量
/// 评论头像宽高 30
FOUNDATION_EXTERN CGFloat const CLMomentCommentViewHeadWH;
/// 评论头像距离顶部的间距 15
FOUNDATION_EXTERN CGFloat const CLMomentCommentViewHeadTopInset;
/// 评论内容距离顶部的间距 35
FOUNDATION_EXTERN CGFloat const CLMomentCommentViewContentTopInset;
/// 评论内容距离底部的间距 12
FOUNDATION_EXTERN CGFloat const CLMomentCommentViewContentBottomInset;
/// 评论内容距离评论View左右屏幕的间距 35
FOUNDATION_EXTERN CGFloat const CLMomentCommentViewContentLeftOrRightInset;
/// 点赞内容距离顶部的间距 10
FOUNDATION_EXTERN CGFloat const CLMomentCommentViewAttitudesTopOrBottomInset;

FOUNDATION_EXTERN NSString * const CLMomentItemViewModelKey;

FOUNDATION_EXTERN CGFloat const CLMomentProfileInfoVipWidthHeight;

/// pictureView最多显示的图片数
FOUNDATION_EXTERN NSUInteger const CLMomentPhotosMaxCount ;
/// pictureView显示图片的最大列数
#define CLMomentMaxCols(__photosCount) ((__photosCount==4)?2:3)


FOUNDATION_EXTERN NSString * const CLVCFreshFetchUnreadMsg;

FOUNDATION_EXTERN NSString * const CLFilterSortTypeKey;
FOUNDATION_EXTERN NSString * const CLFilterSiftParamsKey;
/// 苹方常规字体 10
#define CLRegularFont_10 CLRegularFont(10.0f)
/// 苹方常规字体 11
#define CLRegularFont_11 CLRegularFont(11.0f)
/// 苹方常规字体 12
#define CLRegularFont_12 CLRegularFont(12.0f)
/// 苹方常规字体 13
#define CLRegularFont_13 CLRegularFont(13.0f)
/** 苹方常规字体 14 */
#define CLRegularFont_14 CLRegularFont(14.0f)
/// 苹方常规字体 15
#define CLRegularFont_15 CLRegularFont(15.0f)
/// 苹方常规字体 16
#define CLRegularFont_16 CLRegularFont(16.0f)
/// 苹方常规字体 17
#define CLRegularFont_17 CLRegularFont(17.0f)
/// 苹方常规字体 18
#define CLRegularFont_18 CLRegularFont(18.0f)
/// 苹方常规字体 19
#define CLRegularFont_19 CLRegularFont(19.0f)
/// 苹方常规字体 20
#define CLRegularFont_20 CLRegularFont(20.0f)
/// 全局新鲜背景底色
#define CL_MAIN_FRIENDS [UIColor colorWithHexString:@"#ebebeb"]
/// 全局青色 tintColor
#define CL_MAIN_TINTCOLOR [UIColor colorWithRed:(10 / 255.0) green:(193 / 255.0) blue:(42 / 255.0) alpha:1]

/// 全局细下滑线颜色 以及分割线颜色
#define WXGlobalBottomLineColor     [UIColor colorWithHexString:@"#DDDDDD"]
/// 全局黑色字体
#define WXGlobalBlackTextColor      [UIColor colorWithHexString:@"#666666"]
/// 全局灰色背景
#define WXGlobalGrayBackgroundColor [UIColor colorWithHexString:@"#EFEFF4"]
/// 微信昵称字体颜色
#define CLMomentScreenNameTextColor [UIColor colorWithHexString:@"#333333"]
/// 微信正文（链接、电话）的颜色
#define CLMomentContentUrlTextColor [UIColor colorWithHexString:@"#4380D1"]
/// 微信正文字体颜色
#define CLMomentContentTextColor WXGlobalBlackTextColor
/// 微信时间颜色
#define CLMomentCreatedAtTextColor [UIColor colorWithHexString:@"#737373"]
/// 点击文字高亮的颜色
#define CLMomentTextCLghlightBackgroundColor [UIColor colorWithHexString:@"#C7C7C7"]
/// 单条新鲜背景色
#define CLMomentCellViewBackgroundColor [UIColor wCLteColor]
/// 评论or点赞 view的背景色
#define CLMomentCommentViewBackgroundColor [UIColor colorWithHexString:@"#EBEBEB"]
/// 评论or点赞 view的选中的背景色
#define CLMomentCommentViewSelectedBackgroundColor [UIColor colorWithHexString:@"#EBEBEB"]
/// 点击文字高亮的颜色
#define CLMomentTextCLghlightBackgroundColor [UIColor colorWithHexString:@"#C7C7C7"]
/// 微信昵称字体大小
#define CLMomentScreenNameFont CLMediumFont(16.0f)
/// 微信正文字体大小
#define CLMomentContentFont CLRegularFont_15
/// 微信地址+时间+来源的字体大小
#define CLMomentCreatedAtFont CLRegularFont_12
/// 微信（全文/收起）字体大小
#define CLMomentExpandTextFont CLRegularFont_16
/// 微信评论正文字体大小
#define CLMomentCommentContentFont CLRegularFont_14
/// 微信评论的昵称的字体大小
#define CLMomentCommentScreenNameFont  CLMediumFont(14.0f)

//// ---------------- inline ----------------

/// 图片的宽度 （九宫格）
static inline CGFloat CLMomentPhotosViewItemWidth(){
    CGFloat itemW = ([UIScreen mainScreen].bounds.size.width<=320)? CLMomentPhotosViewItemWH2:CLMomentPhotosViewItemWH1;
    return itemW;
}


/// 单张图片的最大宽度（方形or等比例）
static inline CGFloat CLMomentPhotosViewSingleItemMaxWidth(){
    CGFloat itemW = CLMomentPhotosViewItemWidth();
    return CLMomentPhotosViewItemInnerMargin + itemW*2;
}

/// 计算微信新鲜正文的limitWidth或者评论View的宽度
static inline CGFloat CLMomentCommentViewWidth() {
    return ([UIScreen mainScreen].bounds.size.width - CLMomentContentLeftOrRightInset*2 -CLMomentAvatarWH - CLMomentContentInnerMargin);
}

/// 占位头像
static inline UIImage *CLDefaultAvatar(CLDefaultAvatarType type)
{
    switch (type) {
        case CLDefaultAvatarTypeSmall:
            return [UIImage imageNamed:@"placeholder_60x60"];
            break;
        case CLDefaultAvatarTypeBig:
            return [UIImage imageNamed:@"placeholder_166x166"];
            break;
        default:
            return [UIImage imageNamed:@"placeholder_120x120"];
            break;
    }
}

/// 配图的占位图片
static inline UIImage *CLPicturePlaceholder()
{
    //CL_btn_pic
    return [UIImage imageNamed:@"wx_timeline_image_placeholder"];
}

/// 网络图片的占位图片
static inline UIImage *CLWebImagePlaceholder(){
    return [UIImage imageNamed:@"placeholder_image"];
}

/// 网络头像
static inline UIImage *CLWebAvatarImagePlaceholder(){
    return CLDefaultAvatar(CLDefaultAvatarTypeDefualt);
}

/// 适配
static inline CGFloat CLPxConvertToPt(CGFloat px){
    return ceil(px * [UIScreen mainScreen].bounds.size.width/414.0f);
}


/// 辅助方法 创建一个文件夹
static inline void CLCreateDirectoryAtPath(NSString *path){
    BOOL isDir = NO;
    BOOL isExist = [[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:&isDir];
    if (isExist) {
        if (!isDir) {
            [[NSFileManager defaultManager] removeItemAtPath:path error:nil];
            [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil];
        }
    } else {
        [[NSFileManager defaultManager] createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil];
    }
}
/// 重要数据备份的文件夹路径，通过NSFileManager来访问
static inline NSString *CLAppDocDirPath(){
    return [CLDocumentDirectory stringByAppendingPathComponent:CLAPP_DOC_NAME];
}
/// 通过NSFileManager来获取指定重要数据的路径
static inline NSString *CLFilePathFromWeChatDoc(NSString *filename){
    NSString *docPath = CLAppDocDirPath();
    CLCreateDirectoryAtPath(docPath);
    return [docPath stringByAppendingPathComponent:filename];
}

// 全图新鲜详情底部栏高度 44
FOUNDATION_EXTERN CGFloat const CLVCPhotoMomentBottomBarHeight;
// 全图新鲜详情底部文字高度
FOUNDATION_EXTERN CGFloat const CLVCPhotoMomentBottomBarTextHeight;

#define TOOLBAR_BUTTON_BACK_STRING @"toolbar_goback_normal"
#define TOOLBAR_BUTTON_BACK_HILIGHT_STRING @"toolbar_goback_highlighted"
#define TOOLBAR_BUTTON_FORWARD_STRING @"toolbar_goforward_normal"
#define TOOLBAR_BUTTON_FORWARD_HILIGHT_STRING @"toolbar_forward_highlighted"
#define TOOLBAR_BUTTON_REFRESH_STRING @"menu_refresh_normal"
#define TOOLBAR_BUTTON_STOP_STRING @"toolbar_stop_normal"
#define TOOLBAR_BUTTON_MORE_STRING @"toolbar_more_normal"
#define TOOLBAR_BUTTON_MULTIWINDOW_STRING @"toolbar_multiwindow_normal"

#pragma mark - Notification
// 无图模式
#define kNoImageModeChanged         @"kNoImageModeChanged"
// 护眼模式
#define kEyeProtectiveModeChanged   @"kEyeProtectiveModeChanged"
// tab switch
#define kWebTabSwitch               @"kWebTabSwitch"
// webView navigation change
#define kWebHistoryItemChangedNotification @"WebHistoryItemChangedNotification"
// expand toolbar
#define kExpandHomeToolBarNotification @"kExpandHomeToolBarNotification"
// open in new window
#define kOpenInNewWindowNotification @"kOpenInNewWindowNotification"
// 黑夜模式
#define kNightStatueModeChanged   @"kNightStatueModeChanged"

#define STATUS_BAR_HEIGHT [UIApplication sharedApplication].statusBarFrame.size.height

#define BOTTOM_TOOL_BAR_HEIGHT 44
#define TOP_TOOL_BAR_HEIGHT 70
#define TOP_TOOL_BAR_THRESHOLD 45

#define Card_Cell_Close_Width 50
#define Card_Cell_Close_Height 50

#define TEXT_FIELD_PLACEHOLDER   @"搜索或输入网址"

#define BAIDU_SEARCH_URL @"https://m.baidu.com/s?word=%@&ie=utf-8"

#define DEFAULT_IMAGE @"default"
#define DEFAULT_CARD_CELL_IMAGE @"baidu"
#define DEFAULT_CARD_CELL_URL   @"about:homepage"
#define DEFAULT_CARD_CELL_TITLE @"首页"

static NSString *const KEY_WEB_TITLE        = @"KEY_WEB_TITLE";
static NSString *const KEY_WEB_URL          = @"KEY_WEB_URL";
static NSString *const KEY_WEB_IMAGE        = @"KEY_WEB_IMAGE";
static NSString *const KEY_WEB_IMAGE_URL    = @"KEY_WEB_IMAGE_URL";
static NSString *const KEY_WEB_SESSION_DATA    = @"KEY_WEB_SESSION_DATA";

/// 没有章节了(可以指定为任意标识,默认是空则为没有更多章节)
static NSString *CL_READ_NO_MORE_CHAPTER = nil;
/// 书籍首页-书名页
static NSInteger CL_READ_BOOK_HOME_PAGE = -1;
/// 用于指定章节最后一页
static NSInteger CL_READ_LAST_PAGE = -1;
/// 动画时间
static NSTimeInterval CL_READ_AD_TIME = 0.2;
/// 段落头部双圆角空格
static NSString *CL_READ_PH_SPACE = @"　　";
/// 主文件夹名称
static NSString *CL_READ_FOLDER_NAME = @"CLBookRead";
/// Key - 配置
static NSString *CL_READ_KEY_CONFIGURE = @"CL_READ_CONFIGURE";
/// Key - 阅读记录
static NSString *CL_READ_KEY_RECORD = @"CL_READ_RECORD";
/// Key - 阅读对象
static NSString *CL_READ_KEY_OBJECT = @"CL_READ_OBJECT";
/// Key - 日夜间模式 NO:日间 YES:夜间
static NSString *CL_READ_KEY_MODE_DAY_NIGHT = @"CL_READ_MODE_DAY_NIGHT";
/// 需要处理的章节标题
static inline NSString *CL_READ_CHAPTER_NAME(NSString *name) { return [NSString stringWithFormat:@"\n%@\n\n",name]; }
/// 阅读最小阅读字体大小
static NSInteger CL_READ_FONT_SIZE_MIN = 12;
/// 阅读最大阅读字体大小
static NSInteger CL_READ_FONT_SIZE_MAX = 24;
/// 阅读默认字体大小
static NSInteger CL_READ_FONT_SIZE_DEFAULT = 18;
/// 阅读字体大小叠加指数
static NSInteger CL_READ_FONT_SIZE_SPACE = 2;
/// 章节标题 - 在当前字体大小上叠加指数
static NSInteger CL_READ_FONT_SIZE_SPACE_TITLE = 8;

static CGFloat CL_SPACE_1 = 1;
static CGFloat CL_SPACE_2 = 2;
static CGFloat CL_SPACE_3 = 3;
static CGFloat CL_SPACE_4 = 4;
static CGFloat CL_SPACE_5 = 5;
static CGFloat CL_SPACE_6 = 6;
static CGFloat CL_SPACE_7 = 7;
static CGFloat CL_SPACE_8 = 8;
static CGFloat CL_SPACE_9 = 9;
static CGFloat CL_SPACE_10 = 10;
static CGFloat CL_SPACE_11 = 11;
static CGFloat CL_SPACE_12 = 12;
static CGFloat CL_SPACE_13 = 13;
static CGFloat CL_SPACE_14 = 14;
static CGFloat CL_SPACE_15 = 15;
static CGFloat CL_SPACE_16 = 16;
static CGFloat CL_SPACE_18 = 18;
static CGFloat CL_SPACE_20 = 20;
static CGFloat CL_SPACE_25 = 25;
static CGFloat CL_SPACE_30 = 30;
static CGFloat CL_SPACE_35 = 35;
static CGFloat CL_SPACE_40 = 40;
static CGFloat CL_SPACE_45 = 45;
static CGFloat CL_SPACE_50 = 50;
static CGFloat CL_SPACE_55 = 55;
static CGFloat CL_SPACE_60 = 60;
static CGFloat CL_SPACE_65 = 65;
static CGFloat CL_SPACE_70 = 70;
static CGFloat CL_SPACE_75 = 75;
static CGFloat CL_SPACE_80 = 80;
static CGFloat CL_SPACE_85 = 85;
static CGFloat CL_SPACE_90 = 90;
static CGFloat CL_SPACE_95 = 95;
static CGFloat CL_SPACE_100 = 100;
static CGFloat CL_SPACE_105 = 105;
static CGFloat CL_SPACE_110 = 110;
static CGFloat CL_SPACE_115 = 115;
static CGFloat CL_SPACE_120 = 120;
static CGFloat CL_SPACE_125 = 125;
static CGFloat CL_SPACE_130 = 130;
static CGFloat CL_SPACE_135 = 135;
static CGFloat CL_SPACE_140 = 140;
static CGFloat CL_SPACE_145 = 145;
static CGFloat CL_SPACE_150 = 150;
static CGFloat CL_SPACE_155 = 155;
static CGFloat CL_SPACE_160 = 160;
static CGFloat CL_SPACE_165 = 165;
static CGFloat CL_SPACE_170 = 170;
static CGFloat CL_SPACE_175 = 175;
static CGFloat CL_SPACE_180 = 180;
static CGFloat CL_SPACE_185 = 185;
static CGFloat CL_SPACE_190 = 190;
static CGFloat CL_SPACE_195 = 195;
static CGFloat CL_SPACE_200 = 200;
static CGFloat CL_SPACE_205 = 205;
static CGFloat CL_SPACE_210 = 210;
static CGFloat CL_SPACE_215 = 215;
static CGFloat CL_SPACE_220 = 220;
static CGFloat CL_SPACE_225 = 225;
static CGFloat CL_SPACE_230 = 230;
static CGFloat CL_SPACE_240 = 240;
static CGFloat CL_SPACE_245 = 245;
static CGFloat CL_SPACE_250 = 250;
static CGFloat CL_SPACE_255 = 255;
static CGFloat CL_SPACE_260 = 260;
static CGFloat CL_SPACE_265 = 265;
static CGFloat CL_SPACE_270 = 270;
static CGFloat CL_SPACE_275 = 275;
static CGFloat CL_SPACE_280 = 280;
static CGFloat CL_SPACE_285 = 285;
static CGFloat CL_SPACE_290 = 290;
static CGFloat CL_SPACE_300 = 300;
static CGFloat CL_SPACE_305 = 305;
static CGFloat CL_SPACE_315 = 315;
static CGFloat CL_SPACE_325 = 325;
static CGFloat CL_SPACE_335 = 335;
static CGFloat CL_SPACE_340 = 340;
static CGFloat CL_SPACE_345 = 345;
static CGFloat CL_SPACE_350 = 350;
static CGFloat CL_SPACE_365 = 365;
static CGFloat CL_SPACE_370 = 370;
static CGFloat CL_SPACE_375 = 375;
static CGFloat CL_SPACE_390 = 390;
static CGFloat CL_SPACE_395 = 395;
static CGFloat CL_SPACE_420 = 420;
static CGFloat CL_SPACE_450 = 450;




// MARK: -- 判断系统设备

/// 是4
static inline BOOL Is4() { return SCREENHEIGHT == 480 && SCREENWIDTH == 320; }
/// 是5
static inline BOOL Is5() { return SCREENHEIGHT == 568 && SCREENWIDTH == 320; }
/// 是678
static inline BOOL Is678() { return SCREENHEIGHT == 667 && SCREENWIDTH == 375; }
/// 是678P
static inline BOOL Is678P() { return SCREENHEIGHT == 736 && SCREENWIDTH == 414; }
/// 是X XS
static inline BOOL IsX_XS() { return SCREENHEIGHT == 812 && SCREENWIDTH == 375; }
/// 是XR XSMAX
static inline BOOL IsXR_XSMAX() { return SCREENHEIGHT == 896 && SCREENWIDTH == 414; }
/// 是X系列
static inline BOOL IsX() { return IsX_XS() || IsXR_XSMAX(); }


/// 以iPhone6为比例
static inline CGFloat CL_SIZE(CGFloat size) { return size * (SCREENWIDTH / 375); }

static inline CGFloat CL(CGFloat is45, CGFloat is678, CGFloat is678P, CGFloat isX_XS, CGFloat isXR_XSMAX) {
    if (Is4() || Is5()) return is45;
    else if (Is678()) return is678;
    else if (Is678P()) return is678P;
    else if (IsX_XS()) return isX_XS;
    else return isXR_XSMAX;
}

static inline CGFloat CL_45_XS_XSMAX_other(CGFloat is45, CGFloat isX_XS, CGFloat isXR_XSMAX, CGFloat other) {
    return CL(is45, other, other, isX_XS, isXR_XSMAX);
}

static inline CGFloat CL_XXS_XRXSMAX_other(CGFloat isX_XS, CGFloat isXR_XSMAX, CGFloat other) {
    return CL(other, other, other, isX_XS, isXR_XSMAX);
}

static inline CGFloat CL_45_other(CGFloat is45, CGFloat other) {
    return CL(is45, other, other, other, other);
}

static inline CGFloat CL_X_other(CGFloat isX, CGFloat other) {
    return CL_XXS_XRXSMAX_other(isX, isX, other);
}


// MARK: 范围

/// 阅读范围(阅读顶部状态栏 + 阅读View + 阅读底部状态栏)
static inline CGRect CL_READ_RECT() {
    // 适配 X 顶部
    CGFloat top = CL_X_other(STATUSBAR_HEIGHT - CL_SIZE(CL_SPACE_15), 0);
    // 适配 X 底部
    CGFloat bottom = CL_X_other(CL_SIZE(CL_SPACE_30), 0);
    CGRect rect = CGRectMake(CL_SIZE(CL_SPACE_15), top, SCREENWIDTH - CL_SIZE(CL_SPACE_30), SCREENHEIGHT - top - bottom);
//    NSLog(@"阅读范围(阅读顶部状态栏 + 阅读View + 阅读底部状态栏)%@",NSStringFromCGRect(rect));
    return rect;
}

/// 阅读View范围
static inline CGRect CL_READ_VIEW_RECT() {
    CGRect rect = CL_READ_RECT();
    rect = CGRectMake(rect.origin.x, rect.origin.y + CL_SIZE(CL_SPACE_40), rect.size.width, rect.size.height - CL_SIZE(CL_SPACE_40) - CL_SIZE(CL_SPACE_30) - CL_SIZE(CL_SPACE_10));
//    NSLog(@"阅读View范围:%@",NSStringFromCGRect(rect));
    return rect;
}


/// Font List
static inline UIFont *CL_FONT(CGFloat size) { return [UIFont systemFontOfSize:CL_SIZE(size)]; }
#define CL_FONT_SA_10 CL_FONT(CL_SPACE_10)
#define CL_FONT_SA_12 CL_FONT(CL_SPACE_12)
#define CL_FONT_SA_14 CL_FONT(CL_SPACE_14)
#define CL_FONT_SA_15 CL_FONT(CL_SPACE_15)
#define CL_FONT_SA_16 CL_FONT(CL_SPACE_16)
#define CL_FONT_SA_18 CL_FONT(CL_SPACE_18)


// MARK: UI

/// 设置分割线
static inline UIView *SpaceLine(UIView *view, UIColor *color) {
    
    UIView *spaceLine = [[UIView alloc]init];
    
    spaceLine.backgroundColor = color;
    
    [view addSubview:spaceLine];
    
    return spaceLine;
}

/// 分割线大小
static CGFloat CL_SPACE_LINE = 0.5;

/// 最小高度
static CGFloat CL_SPACE_MIN_HEIGHT = 0.01;


#define CL_COLOR_46_46_46 RGB(46, 46, 46)        // 菜单背景颜色
#define CL_COLOR_58_52_54 RGB(58, 52, 54)        // 阅读背景颜色支持 || 灰色
#define CL_COLOR_124_126_128 RGB(124, 126, 128)  // 阅读上下状态栏字体颜色
#define CL_COLOR_145_145_145 RGB(145, 145, 145)  // 阅读字体颜色
#define CL_COLOR_205_239_205 RGB(205, 239, 205)  // 阅读背景颜色支持
#define CL_COLOR_206_233_241 RGB(206, 233, 241)  // 阅读背景颜色支持
#define CL_COLOR_230_230_230 RGB(230, 230, 230)  // 分割线 || 菜单默认颜色
#define CL_COLOR_238_224_202 RGB(238, 224, 202)  // 阅读背景颜色支持
#define CL_COLOR_253_85_103 RGB(253, 85, 103)    // 粉红色



/// 主题颜色
#define  CL_READ_COLOR_MAIN CL_COLOR_253_85_103

/// 菜单默认颜色
#define CL_READ_COLOR_MENU_COLOR CL_COLOR_230_230_230

/// 菜单背景颜色
#define CL_READ_COLOR_MENU_BG_COLOR [CL_COLOR_46_46_46 colorWithAlphaComponent:0.96]

/// 阅读背景颜色列表
#define CL_READ_BG_COLORS @[UIColor.whiteColor, CL_COLOR_238_224_202, CL_COLOR_205_239_205, CL_COLOR_206_233_241, CL_COLOR_58_52_54, CL_COLOR_58_52_54] //CL_COLOR_BG_0

#define CL_COLOR_BG_0 [UIColor colorWithPatternImage:[UIImage imageNamed:@"read_bg_0_icon"]]

/// 阅读最小阅读字体大小
#define CL_READ_FONT_SIZE_MIN 12

/// 阅读最大阅读字体大小
#define CL_READ_FONT_SIZE_MAX 24

/// 阅读默认字体大小
#define CL_READ_FONT_SIZE_DEFAULT 18

/// 阅读字体大小叠加指数
#define CL_READ_FONT_SIZE_SPACE 2

/// 章节标题 - 在当前字体大小上叠加指数
#define CL_READ_FONT_SIZE_SPACE_TITLE 8



#define CL_SPACE_SA_1  CL_SIZE(CL_SPACE_1)
#define CL_SPACE_SA_2  CL_SIZE(CL_SPACE_2)
#define CL_SPACE_SA_3  CL_SIZE(CL_SPACE_3)
#define CL_SPACE_SA_4  CL_SIZE(CL_SPACE_4)
#define CL_SPACE_SA_5  CL_SIZE(CL_SPACE_5)
#define CL_SPACE_SA_6  CL_SIZE(CL_SPACE_6)
#define CL_SPACE_SA_7  CL_SIZE(CL_SPACE_7)
#define CL_SPACE_SA_8  CL_SIZE(CL_SPACE_8)
#define CL_SPACE_SA_9  CL_SIZE(CL_SPACE_9)
#define CL_SPACE_SA_10  CL_SIZE(CL_SPACE_10)
#define CL_SPACE_SA_15  CL_SIZE(CL_SPACE_15)
#define CL_SPACE_SA_20  CL_SIZE(CL_SPACE_20)
#define CL_SPACE_SA_25  CL_SIZE(CL_SPACE_25)
#define CL_SPACE_SA_30  CL_SIZE(CL_SPACE_30)
#define CL_SPACE_SA_35  CL_SIZE(CL_SPACE_35)
#define CL_SPACE_SA_40  CL_SIZE(CL_SPACE_40)
#define CL_SPACE_SA_45  CL_SIZE(CL_SPACE_45)
#define CL_SPACE_SA_50  CL_SIZE(CL_SPACE_50)
#define CL_SPACE_SA_55  CL_SIZE(CL_SPACE_55)
#define CL_SPACE_SA_60  CL_SIZE(CL_SPACE_60)
#define CL_SPACE_SA_65  CL_SIZE(CL_SPACE_65)
#define CL_SPACE_SA_70  CL_SIZE(CL_SPACE_70)
#define CL_SPACE_SA_75  CL_SIZE(CL_SPACE_75)
#define CL_SPACE_SA_80  CL_SIZE(CL_SPACE_80)
#define CL_SPACE_SA_85  CL_SIZE(CL_SPACE_85)
#define CL_SPACE_SA_90  CL_SIZE(CL_SPACE_90)
#define CL_SPACE_SA_95  CL_SIZE(CL_SPACE_95)
#define CL_SPACE_SA_100  CL_SIZE(CL_SPACE_100)
#define CL_SPACE_SA_105  CL_SIZE(CL_SPACE_105)
#define CL_SPACE_SA_110  CL_SIZE(CL_SPACE_110)
#define CL_SPACE_SA_115  CL_SIZE(CL_SPACE_115)
#define CL_SPACE_SA_120  CL_SIZE(CL_SPACE_120)
#define CL_SPACE_SA_125  CL_SIZE(CL_SPACE_125)
#define CL_SPACE_SA_130  CL_SIZE(CL_SPACE_130)
#define CL_SPACE_SA_135  CL_SIZE(CL_SPACE_135)
#define CL_SPACE_SA_140  CL_SIZE(CL_SPACE_140)
#define CL_SPACE_SA_145  CL_SIZE(CL_SPACE_145)
#define CL_SPACE_SA_150  CL_SIZE(CL_SPACE_150)
#define CL_SPACE_SA_155  CL_SIZE(CL_SPACE_155)
#define CL_SPACE_SA_160  CL_SIZE(CL_SPACE_160)
#define CL_SPACE_SA_165  CL_SIZE(CL_SPACE_165)
#define CL_SPACE_SA_170  CL_SIZE(CL_SPACE_170)
#define CL_SPACE_SA_175  CL_SIZE(CL_SPACE_175)
#define CL_SPACE_SA_180  CL_SIZE(CL_SPACE_180)
#define CL_SPACE_SA_185  CL_SIZE(CL_SPACE_185)
#define CL_SPACE_SA_190  CL_SIZE(CL_SPACE_190)
#define CL_SPACE_SA_195  CL_SIZE(CL_SPACE_195)
#define CL_SPACE_SA_200  CL_SIZE(CL_SPACE_200)
#define CL_SPACE_SA_205  CL_SIZE(CL_SPACE_205)
#define CL_SPACE_SA_210  CL_SIZE(CL_SPACE_210)
#define CL_SPACE_SA_215  CL_SIZE(CL_SPACE_215)
#define CL_SPACE_SA_220  CL_SIZE(CL_SPACE_220)
#define CL_SPACE_SA_225  CL_SIZE(CL_SPACE_225)
#define CL_SPACE_SA_230  CL_SIZE(CL_SPACE_230)
#define CL_SPACE_SA_240  CL_SIZE(CL_SPACE_240)
#define CL_SPACE_SA_245  CL_SIZE(CL_SPACE_245)
#define CL_SPACE_SA_250  CL_SIZE(CL_SPACE_250)
#define CL_SPACE_SA_255  CL_SIZE(CL_SPACE_255)
#define CL_SPACE_SA_260  CL_SIZE(CL_SPACE_260)
#define CL_SPACE_SA_265  CL_SIZE(CL_SPACE_265)
#define CL_SPACE_SA_270  CL_SIZE(CL_SPACE_270)
#define CL_SPACE_SA_275  CL_SIZE(CL_SPACE_275)
#define CL_SPACE_SA_280  CL_SIZE(CL_SPACE_280)
#define CL_SPACE_SA_285  CL_SIZE(CL_SPACE_285)
#define CL_SPACE_SA_290  CL_SIZE(CL_SPACE_290)
#define CL_SPACE_SA_300  CL_SIZE(CL_SPACE_300)
#define CL_SPACE_SA_305  CL_SIZE(CL_SPACE_305)
#define CL_SPACE_SA_315  CL_SIZE(CL_SPACE_315)
#define CL_SPACE_SA_325  CL_SIZE(CL_SPACE_325)
#define CL_SPACE_SA_335  CL_SIZE(CL_SPACE_335)
#define CL_SPACE_SA_340  CL_SIZE(CL_SPACE_340)
#define CL_SPACE_SA_345  CL_SIZE(CL_SPACE_345)
#define CL_SPACE_SA_350  CL_SIZE(CL_SPACE_350)
#define CL_SPACE_SA_365  CL_SIZE(CL_SPACE_365)
#define CL_SPACE_SA_370  CL_SIZE(CL_SPACE_370)
#define CL_SPACE_SA_375  CL_SIZE(CL_SPACE_375)
#define CL_SPACE_SA_390  CL_SIZE(CL_SPACE_390)
#define CL_SPACE_SA_395  CL_SIZE(CL_SPACE_395)
#define CL_SPACE_SA_420  CL_SIZE(CL_SPACE_420)
#define CL_SPACE_SA_450  CL_SIZE(CL_SPACE_450)

/// TabBar高度
#define CLTabBarHeight (IsX() ? 83 : 49)

/// StatusBar高度 (IsX ? 44 : 20)
#define CLStatusBarHeight (IsX() ? 44 : 20)

/// 导航栏高度
#define CLNavgationBarHeight (CLStatusBarHeight + 44)

// MARK: 进度相关

/// 总进度字符串
static inline NSString *CL_READ_TOTAL_PROGRESS_STRING(CGFloat progress) {
    return [NSString stringWithFormat:@"%.1f%%",(floor(progress * 1000) / 10)];
}

/// contentView 宽高
#define CL_READ_CONTENT_VIEW_WIDTH SCREENWIDTH
#define CL_READ_CONTENT_VIEW_HEIGHT SCREENHEIGHT

static inline UIFont * CL_FONT_BOLD_SA(CGFloat size){
    return [UIFont boldSystemFontOfSize:CL_SIZE(size)];
}


// MARK: 延迟执行

/// 延迟执行
#define DelayHandle(delay, execute) dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delay * NSEC_PER_SEC)), dispatch_get_main_queue(), execute)
/// 延迟执行
static inline void DelayDefaultHandle(VoidBlock execute) {
    DelayHandle(0.01, execute);
}




@interface CLConstant : NSObject
@end
